﻿<UserControl x:Class="LockCrypt.AccountView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:conv="clr-namespace:LockCrypt.Converters"
    xmlns:loc="clr-namespace:LockCrypt"
    xmlns:lex="http://schemas.root-project.org/xaml/presentation"
    xmlns:Drawing="clr-namespace:System.Drawing;assembly=System.Drawing"
    xmlns:l49ui="clr-namespace:Lime49.UI;assembly=Lime49"
    x:Name="root">
    <UserControl.CommandBindings>
        <CommandBinding Command="ApplicationCommands.Copy" Executed="CopyToClipboard"/>
        <CommandBinding Command="loc:LockCryptCommands.OpenUrl" Executed="OpenUrl"/>
        <CommandBinding Command="loc:LockCryptCommands.ShowPassword" Executed="ShowPassword"/>
    </UserControl.CommandBindings>
    <UserControl.Resources>
        <conv:NestableTemplateSelector x:Key="NestableTemplateSelector" AccountTemplate="{StaticResource AccountTemplate}" 
                                       GroupLargeIconsTemplate="{StaticResource GroupLargeIconsTemplate}"
                                       GroupSmallIconsTemplate="{StaticResource GroupSmallIconsTemplate}"
                                       GroupDetailsTemplate="{StaticResource GroupDetailsTemplate}"
                                       GroupTilesTemplate="{StaticResource GroupTilesTemplate}"/>
        <conv:NestableToVisibilityConverter x:Key="NestableToVisibilityConverter"/>
    </UserControl.Resources>
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <GroupBox Grid.Row="0" x:Name="grpItems" Style="{StaticResource NestableGroupBox}" Content="{Binding SelectedItem,ElementName=root}" 
                  ContentTemplateSelector="{StaticResource NestableTemplateSelector}">
            <GroupBox.Resources>
                <loc:DefaultDragSourceAdvisor x:Key="NestableDragSourceAdvisor"/>
                <loc:NestableDropTargetAdvisor x:Key="NestableDropTargetAdvisor"/>
                <Style TargetType="{x:Type ListBoxItem}" BasedOn="{StaticResource {x:Type ListBoxItem}}">
                    <EventSetter Event="MouseDoubleClick" Handler="lst_MouseDoubleClick"/>
                    <Setter Property="loc:DragDropManager.DragSourceAdvisor" Value="{StaticResource NestableDragSourceAdvisor}"/>
                    <Setter Property="loc:DragDropManager.DropTargetAdvisor" Value="{StaticResource NestableDropTargetAdvisor}"/>
                </Style>
            </GroupBox.Resources>
            <GroupBox.HeaderTemplate>
                <DataTemplate>
                    <DataTemplate.Resources>
                        <conv:IconConverter x:Key="IconConverter"/>
                    </DataTemplate.Resources>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="Auto"/>
                            <ColumnDefinition Width="*"/>
                        </Grid.ColumnDefinitions>
                        <Border Grid.Column="0" Grid.ColumnSpan="2" Background="{StaticResource hoverGradient}" Opacity="0.5"/>
                        <Image Grid.Column="0" Source="{Binding SelectedItem.Icon,Converter={StaticResource IconConverter},ConverterParameter=64,RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}"  Stretch="Uniform" Width="64" Height="64"
                                Margin="1,1,6,1"/>
                        <TextBlock Grid.Column="1" Text="{Binding SelectedItem.Name,RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" 
                               TextWrapping="Wrap" TextTrimming="CharacterEllipsis" FontSize="40" VerticalAlignment="Center" />
                    </Grid>
                </DataTemplate>
            </GroupBox.HeaderTemplate>
        </GroupBox>
        <StatusBar Grid.Row="1"  Visibility="{Binding SelectedItem,ElementName=root,Converter={StaticResource NestableToVisibilityConverter},ConverterParameter=group}">
            <StatusBar.ItemsPanel>
                <ItemsPanelTemplate>
                    <Grid>
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                    </Grid>
                </ItemsPanelTemplate>
            </StatusBar.ItemsPanel>
            <TextBlock x:Name="lblRecordCount" Grid.Column="0" TextTrimming="CharacterEllipsis" TextWrapping="NoWrap" Margin="2" />
            <!--49:ImageButton x:Name="btnAutoType" Grid.Column="1" MinWidth="18" Text="{lex:LocText LockCrypt.Core:Strings:AutoType}" Command="loc:LockCryptCommands.AutoType"
                             Image="pack://application:,,,/Resources/images/keyboard_16.png" ImageLocation="Left" ShowText="False" AlwaysShowBorder="False" Margin="1"
                             CommandParameter="{Binding SelectedItem,ElementName=root}"
                             Visibility="{Binding SelectedItem,ElementName=root,Converter={StaticResource NestableToVisibilityConverter},ConverterParameter=account}"/-->
        </StatusBar>
    </Grid>
</UserControl>
